const express = require('express')

// 引入路由
const musicRouter = require('./router/music')
const homeRouter = require('./router/home')
const indexRouter = require('./router/index')
const recommendRouter = require('./router/recommend')
const frontEndRouter = require('./router/frontEnd')
// 引入cors
const cors = require('cors')

const app = express()

// 配置跨域
app.use(cors())
// 定义中间件
app.use((req,res,next)=>{
    // code 默认为201
    // err 错误信息
    res.cc=(err,code = 201) =>{
        res.send({
            code,
            msg:err
        })
    }
    next()
})

app.use('/',musicRouter)
app.use('/home',homeRouter)
app.use('/',indexRouter)
app.use('/',recommendRouter)
app.use('/',frontEndRouter)

app.listen(8000,()=>{
    console.log('服务器启动中 地址：http://127.0.0.1:8000')
})